home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Libraries / Animation Class Library / CCL / Core Class Library V1.1c / Headers / CoreNode.h < prev   
Encoding:
C/C++ Source or Header  |  1994-08-06  |  4.3 KB  |  138 lines  |  [TEXT/MPCC]

  1.  
  2. /********************************************
  3.  **** Core Class V1.1 © 1993-94 Yves Schmid & Alia Development
  4.  ****
  5.  **** CoreNode.h
  6.  ****
  7.  **** Authors:        Yves Schmid and Odorico von Susani  
  8.  **** Created:      14 November 1993
  9.  **** Modified:     08 August 1994
  10.  **** Compatible:   C++
  11.  **** Version:      1.1
  12.  **** Description:  This class is part of the linked list system of the Core class system.
  13.  ****                When you create a class which must be linked to a CoreList, you
  14.  ****                must create a superclass of CoreNode. A CoreNode contains a pointer
  15.  ****                on the next node (or NULL), a pointer on the previous node (or NULL) and
  16.  ****                a pointer on his CoreList.
  17.  ****
  18.  ****                When you build a CoreNode you give the constructor a pointer
  19.  ****                on a CoreList. If you don't give a CoreList, the node will remain
  20.  ****                unlinked.
  21.  ****
  22.  ****                A previously built CoreNode can be linked to a CoreList with
  23.  ****                the "setlist" method . "Setlist" is smart enough to unlink
  24.  ****                the CoreNode if it has already been linked to another list.
  25.  ****                You can pass NULL to "setlist" if you just want to unlink
  26.  ****                your node (same as calling "remove").
  27.  ****
  28.  ****                The destructor unlinks the node from his list for you. You
  29.  ****                don't have to unlink a node before destroying it.
  30.  ****
  31.  ****                For parsing a list you can use this code:
  32.  ****
  33.  ****                for(CoreNode *n = list->getfirst();n;n=n->getnext()) {...}
  34.  ****
  35.  ****               You may want to use the message system:
  36.  ****
  37.  ****                list->docmd(CCMD_EXAMPLE,CCF_NODES);   // From a CoreList
  38.  ****                node->docmd(CCMD_EXAMPLE,CCF_NODES);   // From a CoreNode
  39.  ****
  40.  ****
  41.  ****                When a node is duplicated it is added to the same CoreList as
  42.  ****                the original node. You can remove it or link it to another
  43.  ****                list using the "setlist" method.
  44.  ****
  45.  *************************/
  46.  
  47.  
  48. #ifndef CoreNode_H
  49. #define CoreNode_H
  50.  
  51.  
  52. #include "Core.h"
  53. #include "CoreList.h"
  54.  
  55. class CoreList;
  56. class CoreHead;
  57.  
  58. //.......................................
  59. // CoreNode
  60.  
  61. class CoreNode: public Core
  62. {
  63.  
  64.     //***********************************************************
  65.     //.............. P U B L I C   M E T H O D S.................
  66.  
  67.     public:
  68.  
  69.  
  70.     CoreNode(void);                  // No link
  71.     CoreNode(CoreList *);            // Linked to a CoreList
  72.  
  73.     virtual ~CoreNode(void);
  74.  
  75.  
  76.  
  77.     virtual void setlist(CoreList *);                        // Link to a list
  78.     virtual void sethead(CoreHead *ahead, long entry);     // Link to a head (See "CoreHead.h")
  79.  
  80.     virtual void setlist(CoreList *, long position);       // Link to a list at a position
  81.     
  82.     virtual void setsamelistas(CoreNode *, Boolean insertbefore =FALSE); 
  83.                                                           // Link to the same list as the passed
  84.                                                           // CoreNode. If "insertbefore" is TRUE
  85.                                                           // object is inserted before the passed
  86.                                                           // CoreNode else it is linked after.
  87.  
  88.  
  89.  
  90.     inline CoreList *getlist(void) const {return list;}         // return list
  91.     inline CoreNode *getnext(void) const {return next;}          // return next
  92.     inline CoreNode *getprevious(void) const {return previous;} // return previous
  93.  
  94.  
  95.  
  96.     virtual void remove(void);          // Unlink from his CoreList
  97.  
  98.     virtual Core *duplicate(void);   // Duplicate. If this object has a list, the
  99.                                      // duplicated object is linked to the same
  100.                                      // list. Use "remove" if you want to unlink
  101.                                      // the duplicated object.
  102.  
  103.     //***********************************************************
  104.  
  105.  
  106.     public:
  107.  
  108.     //..........................................................
  109.     // You should not call the following methods!
  110.  
  111.     inline void setlistptr(CoreList *a){list = a;}
  112.     inline void setprevious(CoreNode *un) {previous = un;}
  113.     inline void setnext(CoreNode *un) {next = un;}
  114.     
  115.    
  116.     virtual void sendcmd(long cmd, short flags=0, void *info=NULL,    // (Only for internal use)
  117.                            short t=0, void *parent=NULL);
  118.  
  119.     virtual void copyfrom(Core *uo); // The magic duplication system (see "Core.h")
  120.  
  121.     //..........................................................
  122.  
  123.  
  124.     private:
  125.  
  126.     CoreNode   *next;          // Link
  127.     CoreNode   *previous;
  128.     CoreList   *list;          // Its list or NULL
  129.  
  130.  
  131.     void linknode(void);    // Link a node (internal use only)
  132.  
  133. };
  134.  
  135.  
  136. #endif
  137.  
  138.